package cn.numeron.common.utility

import cn.numeron.okhttp.OAuthProvider

object HeadersManager : OAuthProvider {

    private val headerMap = mutableMapOf(
        "__tenant" to "",
        "Accept-Language" to "zh-Hans",
        "Accept" to "application/json"
    )

    override val headers: Map<String, String>
        get() = headerMap

    var accessToken: String?
        get() = headerMap[KEY_ACCESS_TOKEN]
        set(value) {
            if (value.isNullOrEmpty()) {
                headerMap.remove(KEY_ACCESS_TOKEN)
            } else {
                headerMap[KEY_ACCESS_TOKEN] = "Bearer $value"
            }
        }

    override fun refreshToken(): String? {
        return null
    }

    const val KEY_ACCESS_TOKEN = "Authorization"

}